package com.example.finalwork.Pay;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.finalwork.DAO.PayDAO;
import com.example.finalwork.Entity.Pay;
import com.example.finalwork.LoginActivity;
import com.example.finalwork.R;
import com.example.finalwork.lmpl.PayDAOlmpl;

import java.util.List;

public class PayGetAllActivity extends AppCompatActivity implements View.OnClickListener{
    private LinearLayout ll_content2;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_paygetall);

        findViewById(R.id.button4).setOnClickListener(this);

        ll_content2 = findViewById(R.id.ll_content2);

        PayDAO payDAO = new PayDAOlmpl(this);
        List<Pay> pays = payDAO.GetAllPay();
        for(int i = 0 ; i < pays.size() ; i++)
        {
            Pay pay = pays.get(i);
            if(pay.getPay_User().equals(LoginActivity.data))
            {
                TextView textView2 = new TextView(this);
                textView2.setText("\t\t\t\t\t\t"+String.valueOf(pay.getPay_Id()) + "\t\t\t\t\t\t\t\t\t\t\t\t" + pay.getPay_Name() + "\t\t\t\t\t\t\t\t\t\t" + pay.getPay_Date() + "\t\t\t\t\t\t\t\t\t" + pay.getPay_Amount() + "\t\t\t\t\t\t\t\t\t" + pay.getPay_Remark());
                textView2.setTextSize(18);
                ll_content2.addView(textView2);
            }
        }
        setTitle("查看所有支出项目功能");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button4:
                Toast.makeText(this,"返回上一级",Toast.LENGTH_SHORT).show();
                startActivity(new Intent(this, PayMainActivity.class));
                break;
        }

    }
}
